package com.qdlc.p2p.common.constant;

import org.springframework.util.StringUtils;

/**
 * 代收/代付常量
 * 通过summaryType来确定回调后的类型
 * @author linya 2016-01-12
 */
public enum Summary {

	LOAN("loan", "放款"),
	REPAY("repay", "还款"),
	CASH_RED_ENVELOPE_EXCHAGE("red_envelope_exchange", "现金红包兑换"),
	CASH_WINE_COUPONS_EXCHAGE("wine_coupons_exchange", "现金酒券兑换"),
    VIRTUAL_RED_ENVELOPE_EXCHAGE("red_envelope_exchange", "虚拟红包兑换"),
    VIRTUAL_WINE_COUPONS_EXCHAGE("wine_coupons_exchange", "虚拟酒券兑换"),
	TENDER("tender", "手动投标"),
	AUTO_TENDER("autoTender", "自动投标"),
	CASH_LOTTERY_EXCHAGE("cash_lottery_exchange","普通抽奖现金兑换"),
	SCORE_LOTTERY_EXCHAGE("score_lottery_exchange","积分抽奖现金兑换"),
	REFUND("refund", "退款"),
	VIRTUAL("virtual", "虚拟金"),
	CASH_FEE("cash_fee", "提现手续费"),
	CASH_AWARD("cash_award","投标现金奖励"),
	EXPERIENCE_INTEREST("experience_interest", "体验金利息"),
	OTHER("other", "其他");
	
	String summaryType;
	String summaryName;
	
	Summary(String summaryType, String summaryName){
		this.summaryName = summaryName;
		this.summaryType = summaryType;
	}
	
	public String getSummaryType() {
		return summaryType;
	}

	public String getSummaryName() {
		return summaryName;
	}

	public static String getSummaryNameByType(String summaryType){
		return getSummaryByType(summaryType).getSummaryName();
	}
	
	public static Summary getSummaryByType(String summaryType){
		if(!StringUtils.hasText(summaryType)){
			return OTHER;
		}
		for(Summary entry: Summary.values()){
			if(entry.summaryType.equals(summaryType)){
				return entry;
			}
		}
		return OTHER;
	}
	
}
